/* Copyright (c) 2017, NVIDIA CORPORATION.  All rights reserved.
*
* NVIDIA CORPORATION and its licensors retain all intellectual property
* and proprietary rights in and to this software, related documentation
* and any modifications thereto.  Any use, reproduction, disclosure or
* distribution of this software and related documentation without an express
* license agreement from NVIDIA CORPORATION is strictly prohibited.
*/
#include "NVIDIAGfeSDKPrivatePCH.h"
#include "TypeTranslation.h"



using namespace GfeSDK;

std::map<NVGSDK_Scope, EGfeSDKScope> kScopeSdkToUnreal = {
    { NVGSDK_SCOPE_HIGHLIGHTS, EGfeSDKScope::Highlights },
    { NVGSDK_SCOPE_HIGHLIGHTS_VIDEO, EGfeSDKScope::HighlightsRecordVideo },
    { NVGSDK_SCOPE_HIGHLIGHTS_SCREENSHOT, EGfeSDKScope::HighlightsRecordScreenshot },
    { NVGSDK_SCOPE_MAX, EGfeSDKScope::MAX },
};
std::map<EGfeSDKScope, NVGSDK_Scope> kScopeUnrealToSdk = InvertMap(kScopeSdkToUnreal);

std::map<NVGSDK_Permission, EGfeSDKPermission> kPermissionSdkToUnreal = {
    { NVGSDK_PERMISSION_GRANTED, EGfeSDKPermission::Granted },
    { NVGSDK_PERMISSION_DENIED, EGfeSDKPermission::Denied },
    { NVGSDK_PERMISSION_MUST_ASK, EGfeSDKPermission::MustAsk },
    { NVGSDK_PERMISSION_UNKNOWN, EGfeSDKPermission::Unknown },
    { NVGSDK_PERMISSION_MAX, EGfeSDKPermission::MAX }
};
std::map<EGfeSDKPermission, NVGSDK_Permission> kPermissionUnrealToSdk = InvertMap(kPermissionSdkToUnreal);

std::map<NVGSDK_HighlightType, EGfeSDKHighlightType> kHighlightTypeSdkToUnreal = {
    { NVGSDK_HIGHLIGHT_TYPE_MILESTONE, EGfeSDKHighlightType::Milestone },
    { NVGSDK_HIGHLIGHT_TYPE_ACHIEVEMENT, EGfeSDKHighlightType::Achievement },
    { NVGSDK_HIGHLIGHT_TYPE_INCIDENT, EGfeSDKHighlightType::Incident },
    { NVGSDK_HIGHLIGHT_TYPE_STATE_CHANGE, EGfeSDKHighlightType::StateChange },
	{ NVGSDK_HIGHLIGHT_TYPE_UNANNOUNCED, EGfeSDKHighlightType::Unannounced },
    { NVGSDK_HIGHLIGHT_TYPE_MAX, EGfeSDKHighlightType::MAX }
};
std::map<EGfeSDKHighlightType, NVGSDK_HighlightType> kHighlightTypeUnrealToSdk = InvertMap(kHighlightTypeSdkToUnreal);

std::map<NVGSDK_HighlightSignificance, EGfeSDKHighlightSignificance> kHighlightSignificanceSdkToUnreal = {
    { NVGSDK_HIGHLIGHT_SIGNIFICANCE_EXTREMELY_BAD, EGfeSDKHighlightSignificance::ExtremelyBad },
    { NVGSDK_HIGHLIGHT_SIGNIFICANCE_VERY_BAD, EGfeSDKHighlightSignificance::VeryBad },
    { NVGSDK_HIGHLIGHT_SIGNIFICANCE_BAD, EGfeSDKHighlightSignificance::Bad },
    { NVGSDK_HIGHLIGHT_SIGNIFICANCE_NEUTRAL, EGfeSDKHighlightSignificance::Neutral },
    { NVGSDK_HIGHLIGHT_SIGNIFICANCE_GOOD, EGfeSDKHighlightSignificance::Good },
    { NVGSDK_HIGHLIGHT_SIGNIFICANCE_VERY_GOOD, EGfeSDKHighlightSignificance::VeryGood },
    { NVGSDK_HIGHLIGHT_SIGNIFICANCE_EXTREMELY_GOOD, EGfeSDKHighlightSignificance::ExtremelyGood },
    { NVGSDK_HIGHLIGHT_SIGNIFICANCE_MAX, EGfeSDKHighlightSignificance::MAX }
};
std::map<EGfeSDKHighlightSignificance, NVGSDK_HighlightSignificance> kHighlightSignificanceUnrealToSdk = InvertMap(kHighlightSignificanceSdkToUnreal);

EGfeSDKReturnCode TranslateReturnCodeToUnreal(NVGSDK_RetCode code)
{
	switch (code)
	{
	case NVGSDK_SUCCESS:                    return EGfeSDKReturnCode::Success;
	case NVGSDK_SUCCESS_VERSION_OLD_SDK:    return EGfeSDKReturnCode::SuccessIpcOldSdk;
	case NVGSDK_SUCCESS_VERSION_OLD_GFE:    return EGfeSDKReturnCode::SuccessIpcOldGfe;
	case NVGSDK_ERR_GFE_VERSION:            return EGfeSDKReturnCode::ErrorGfeVersion;
	case NVGSDK_ERR_SDK_VERSION:            return EGfeSDKReturnCode::ErrorSdkVersion;
	case NVGSDK_ERR_GENERIC:				return EGfeSDKReturnCode::ErrorGeneric;
	case NVGSDK_ERR_NOT_IMPLEMENTED:        return EGfeSDKReturnCode::ErrorNotImplemented;
	case NVGSDK_ERR_INVALID_PARAMETER:      return EGfeSDKReturnCode::ErrorInvalidParameter;
	case NVGSDK_ERR_NOT_SET:				return EGfeSDKReturnCode::ErrorNotSet;
	case NVGSDK_ERR_SHADOWPLAY_IR_DISABLED: return EGfeSDKReturnCode::ErrorShadowplayIRDisabled;
	case NVGSDK_ERR_SDK_IN_USE:				return EGfeSDKReturnCode::ErrorSDKInUse;
	case NVGSDK_ERR_GROUP_NOT_FOUND:        return EGfeSDKReturnCode::ErrorGroupNotFound;
	case NVGSDK_ERR_FILE_NOT_FOUND:         return EGfeSDKReturnCode::ErrorFileNotFound;
	case NVGSDK_ERR_HIGHLIGHTS_SETUP_FAILED:return EGfeSDKReturnCode::ErrorHighlightsSetupFailed;
	case NVGSDK_ERR_HIGHLIGHTS_NOT_CONFIGURED:	return EGfeSDKReturnCode::ErrorHighlightsNotConfigured;
	case NVGSDK_ERR_HIGHLIGHTS_SAVE_FAILED: return EGfeSDKReturnCode::ErrorHighlightSaveFailed;
	case NVGSDK_ERR_UNEXPECTED_EXCEPTION:   return EGfeSDKReturnCode::ErrorUnexpectedException;
	case NVGSDK_ERR_NO_HIGHLIGHTS:          return EGfeSDKReturnCode::ErrorNoHighlights;
	case NVGSDK_ERR_NO_CONNECTION:          return EGfeSDKReturnCode::ErrorNoConnection;
	case NVGSDK_ERR_PERMISSION_NOT_GRANTED: return EGfeSDKReturnCode::ErrorPermissionNotGranted;
	case NVGSDK_ERR_PERMISSION_DENIED:      return EGfeSDKReturnCode::ErrorPermissionDenied;
	case NVGSDK_ERR_INVALID_HANDLE:         return EGfeSDKReturnCode::ErrorInvalidHandle;
	case NVGSDK_ERR_UNHANDLED_EXCEPTION:    return EGfeSDKReturnCode::ErrorUnhandledException;
	case NVGSDK_ERR_OUT_OF_MEMORY:          return EGfeSDKReturnCode::ErrorOutOfMemory;
	case NVGSDK_ERR_LOAD_LIBRARY:           return EGfeSDKReturnCode::ErrorLoadLibrary;
	case NVGSDK_ERR_LIB_CALL_FAILED:        return EGfeSDKReturnCode::ErrorLibraryCallFailed;
	case NVGSDK_ERR_IPC_FAILED:				return EGfeSDKReturnCode::ErrorIPCFailed;
	case NVGSDK_ERR_CONNECTION:				return EGfeSDKReturnCode::ErrorConnection;
	case NVGSDK_ERR_MODULE_NOT_LOADED:      return EGfeSDKReturnCode::ErrorModuleNotLoaded;
	case NVGSDK_ERR_LIB_CALL_TIMEOUT:       return EGfeSDKReturnCode::ErrorLibCallTimeout;
	case NVGSDK_ERR_APPLICATION_LOOKUP_FAILED:return EGfeSDKReturnCode::ErrorApplicationLookupFailed;
	case NVGSDK_ERR_APPLICATION_NOT_KNOWN:  return EGfeSDKReturnCode::ErrorApplicationNotKnown;
	case NVGSDK_ERR_FEATURE_DISABLED:       return EGfeSDKReturnCode::ErrorFeatureDisabled;
	case NVGSDK_ERR_APP_NO_OPTIMIZATION:    return EGfeSDKReturnCode::ErrorAppNoOptimization;
	case NVGSDK_ERR_APP_SETTINGS_READ:      return EGfeSDKReturnCode::ErrorAppSettingsRead;
	case NVGSDK_ERR_APP_SETTINGS_WRITE:     return EGfeSDKReturnCode::ErrorAppSettingsWrite;

	}

    return (NVGSDK_SUCCEEDED(code) ? EGfeSDKReturnCode::Success : EGfeSDKReturnCode::Error);
}
